Xbasic

GET_INDEX_DEFINITIONS Function

Syntax

Definitions as C = Get_Index_Definitions(C tablename )

Arguments

Definitions

A CR-LF delimited list of index definitions. The format of each definition is: Tag_Name | Index_Expr | Filter_Expr | Index_Type

Argument
Description
Tag_Name

Any character string, up to 32 characters long, used to identify the index. Spaces are not permitted in the tag name.

Index_Expr

A character expression indicating the field or combination of fields used to order the index.

Filter_Expr

Optional. Default = all records. A logical expression that indicates the field value(s) that must be satisfied in order for a record to be included in the index.

Index_Type

Optional. A string of character flags that can specify a descending sort order ('D'), or include only records with unique key values ('U'). By default, an index is ascending and includes duplicate key values.

tablename

The name of the table whose indexes you are examining.

Description

Gets the definitions of all index tags in a table's index file. Format is: tagname|OrderExpn|FilterExpn|Flags. Returns a CRLF delimited string. Use create_indexes() to rebuild indexes using this definition string.

Discussion

The GET_INDEX_DEFINITIONS() function returns a CR-LF delimited string of the definitions of all indexes (i.e. index tags) for a table. This function is useful for taking a snapshot of the indexes in a particular table. You can then have code in your application that checks the current indexes in the table and compares them with the saved snapshot. If there is a mismatch, the missing index tags can be recreated with CREATE_INDEXES().

Example

? Get_Index_Definitions("index_entries")
= Entry|PADR(LEFT(ENTRY,40),40," ") + PADR(LEFT(SUBENTRY,40),40," ") + PADR(LEFT(TOPIC,40),40, " ")||
Index_Id|INDEX_ID||U

See Also